﻿using System;
using System.ComponentModel;
using System.Linq;
using ProjectEuler.Extensions;
using ProjectEuler.Linq;

namespace ProjectEuler.Problems
{
    [EulerProblem(28, 669171001)]
    [Description("What is the sum of both diagonals in a 1001 by 1001 spiral?")]
    internal sealed class Problem028 : EulerProblem
    {
        public override Object Solve()
        {
            var last = 1;
            var result = 1;
            var increment = 2;

            while (increment < 1001)
            {
                for (int i = 0; i < 4; i++)
                {
                    last += increment;
                    result += last;
                }

                increment += 2;
            }

            return result;
        }
    }
}
